package com.ming.server.dubbo.util;

import java.sql.DriverManager;
import java.sql.SQLException;

import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;

public class DBUtil {

	private static final String url = "jdbc:mysql://localhost:3306/dubbo";

	private static final String user = "root";

	private static final String password = "123456";

	private static final String name = "com.mysql.jdbc.Driver";

	public Connection conn = null;

	public PreparedStatement pst = null;

	public DBUtil(String sql) {

		try {

			Class.forName(name);

			conn = (Connection) DriverManager.getConnection(url, user, password);
			pst = (PreparedStatement) conn.prepareStatement(sql);

		} catch (Exception e) {

			e.printStackTrace();

		}

	}

	public void close() {

		try {

			this.conn.close();

			this.pst.close();

		} catch (SQLException e) {

			e.printStackTrace();

		}

	}

}
